Use the light nodes to create sources of light for a Scene in your Kanzi application.
Kanzi has these light node types:
Lights contain properties that are passed as uniforms to shaders when Kanzi renders 3D nodes. Lights affect only the rendering of nodes which use materials with shaders that use those lights. In Kanzi the Phong material types by default support one directional light, two point lights, and one spot light. See Setting the number of lights for a material type.
To create a light node:
For each material type you can set the type and number of lights the materials which are based of these material types can use to render nodes.
To set the number of lights for a material type
To create and set a directional light:
// Create a directional light named Directional light. LightSharedPtr directionalLight = Light::createDirectional(domain, "Directional light"); // Rotate the directional light node by -45 degrees around the x axis. SRTValue3D layoutTransformation = directionalLight->getLayoutTransformation(); layoutTransformation.setRotation(Vector3(kzsDegreesToRadians(-45.0f), 0.0f, 0.0f)); directionalLight->setLayoutTransformation(layoutTransformation); // Set the color of the directional light to red. directionalLight->setDirectionalLightColor(ThemeRed);
To create and set a point light:
// Create a point light named Point light. LightSharedPtr pointLight = Light::createPoint(domain, "Point light"); // Move the point light on y axis by 4 units. SRTValue3D layoutTransformation = pointLight->getLayoutTransformation(); layoutTransformation.setTranslation(Vector3(0.0f, 4.0f, 0.0f)); pointLight->setLayoutTransformation(layoutTransformation); // Set the color of the point light to green. pointLight->setPointLightColor(ThemeGreen); // Set the constant attenuation for the point light to 0.8, and linear and quadratic attenuation to 0. pointLight->setPointLightAttenuation(Vector3(0.8f, 0.0f, 0.0f));
To create and set a spot light:
// Create a spot light named Spot light. LightSharedPtr spotLight = Light::createSpot(domain, "Spot light"); // Move the spot light on x axis by 4 units and rotate it around the y axis by 90 degrees. SRTValue3D layoutTransformation = spotLight->getLayoutTransformation(); layoutTransformation.setTranslation(Vector3(4.0f, 0.0f, 0.0f)); layoutTransformation.setRotation(Vector3(0.0f, kzsDegreesToRadians(90.0f), 0.0f)); spotLight->setLayoutTransformation(layoutTransformation); // Set the color of the spot light to blue. spotLight->setSpotLightColor(ThemeBlue); // Set the angle of the spot light cone to 45 degrees. spotLight->setSpotLightCutoffAngle(45.0f); // Set how concentrated the spot light is. spotLight->setSpotLightExponent(30.0f); // Set the constant attenuation for the spot light to 1.3, and linear and quadratic attenuation to 0. spotLight->setSpotLightAttenuation(Vector3(1.3f, 0.0f, 0.0f));
For details, see the Light
class in the API reference.
For lists of the available property types for the light nodes, see: